home *** CD-ROM | disk | FTP | other *** search
- Path: rap.SanDiegoCA.ATTGIS.COM!es013!jbc
- From: jbc@ElSegundoCA.ATTGIS.COM (Jim Chapman)
- Newsgroups: comp.lang.c++
- Subject: Re: No struct in C++!!?
- Date: 15 Feb 1996 22:36:54 GMT
- Organization: AT&T Global Information Solutions
- Distribution: world
- Message-ID: <4g0ci6$t55@rap.SanDiegoCA.ATTGIS.COM>
- References: <31235E0C.252C@idi.oclc.org>
- Reply-To: jbc@ElSegundoCA.ATTGIS.COM
- NNTP-Posting-Host: es013.elsegundoca.attgis.com
-
- In article 252C@idi.oclc.org, Ron Unterreiner <runterreiner@idi.oclc.org> () writes:
- > Georg Woste wrote:
- > >
- > > Hi,
- > >
- > > a beginners question: I found in different C++ books examples of C++ programms
- > > which contain type declarations and definitions in the main() programm - for
- > > example a struct - as in C.
- > > My question is, whether this is a contradiction
- > > to the paradigm of C++. Shouldn't be everything in a C++ programm
- > > either classes, objects or the interaction between objects?
- > > So is it bad C++ style, to use functions or data outside from
- > > classes (objects)?
- > >
- > > Thanks!
- > >
- > > Georg Woeste
- >
-
- > A class is a struct. Anywhere you see the word struct you can substitute
- > the word class. [..]
-
- Correct so far.
-
- > [..] The major thing a class gives you that a C struct
- > doesn't is the ability to protect data. [rest deleted]
-
- Not true. The only difference is the *default* encapsulation level. Struct
- and class are fundamentally interchangable. The following two definitions
- are absolutely equivalent:
-
- struct Foo { // stuff... };
- classs Foo { public: // stuff... };
-
- It is also perfectly legitimate to alternate usage 'struct' and 'class' with
- the same typename, like this:
-
- class Foo; // forward declaration of Foo as class
- struct Foo { ... }; // definition of Foo as struct
-
- ---------------
- Jim Chapman NCR Corporation
- jbc@ElSegundoCA.NCR.COM Parallel Systems Division
-
-